API Documentation
Vector.h
1 // Vector.h
3 //
5 
6 namespace nkMaths
7 {
11  class Vector : public ByteAlignedClass<16>
12  {
13  public :
14 
15  // Attributes
16  float _x ;
17  float _y ;
18  float _z ;
19  float _w ;
20 
21  public :
22 
27  Vector () ;
36  Vector (float x, float y) ;
46  Vector (float x, float y, float z) ;
55  Vector (float x, float y, float z, float w) ;
61  Vector (const Vector& other) ;
67  Vector (const IntVector& other) ;
71  ~Vector () ;
72 
73  // Length
77  float getLengthVec2 () const ;
81  float getLengthVec3 () const ;
85  float getLengthVec4 () const ;
91  float getLengthSquaredVec2 () const ;
97  float getLengthSquaredVec3 () const ;
103  float getLengthSquaredVec4 () const ;
104  // Distance
109  float getDistanceVec2 (const Vector& other) const ;
114  float getDistanceVec3 (const Vector& other) const ;
119  float getDistanceVec4 (const Vector& other) const ;
126  float getDistanceSquaredVec2 (const Vector& other) const ;
133  float getDistanceSquaredVec3 (const Vector& other) const ;
140  float getDistanceSquaredVec4 (const Vector& other) const ;
141 
147  void normalizeVec2 () ;
153  void normalizeVec3 () ;
157  void normalizeVec4 () ;
170  // Dot product
177  float dotProductVec2 (const Vector& other) const ;
184  float dotProductVec3 (const Vector& other) const ;
191  float dotProductVec4 (const Vector& other) const ;
192  // Cross product
198  void setAsCrossVec3 (const Vector& other) ;
205  Vector getCrossVec3 (const Vector& other) const ;
206 
207  // Practical
218  void fromString (const nkMemory::StringView& str) ;
219 
220  // Operators
227  Vector& operator= (const Vector& other) ;
234  Vector& operator= (const IntVector& other) ;
241  Vector operator+ (const Vector& other) const ;
247  void operator+= (const Vector& other) ;
254  Vector operator- (const Vector& other) const ;
260  void operator-= (const Vector& other) ;
267  Vector operator* (const Vector& other) const ;
273  void operator*= (const Vector& other) ;
280  Vector operator* (const Quaternion& other) const ;
286  void operator*= (const Quaternion& other) ;
293  Vector operator* (const Matrix& mat) const ;
299  void operator*= (const Matrix& other) ;
306  Vector operator* (float coeff) const ;
312  void operator*= (float coeff) ;
319  Vector operator/ (const Vector& other) const ;
325  void operator/= (const Vector& other) ;
332  Vector operator/ (float coeff) const ;
338  void operator/= (float coeff) ;
345  bool operator== (const Vector& other) const ;
352  bool operator!= (const Vector& other) const ;
359  bool operator< (const Vector& other) const ;
366  bool operator<= (const Vector& other) const ;
373  bool operator> (const Vector& other) const ;
380  bool operator>= (const Vector& other) const ;
381 
382  // Statics
383  // Distance
391  static float distanceVec2 (const Vector& a, const Vector& b) ;
399  static float distanceVec3 (const Vector& a, const Vector& b) ;
407  static float distanceVec4 (const Vector& a, const Vector& b) ;
415  static float distanceSquaredVec2 (const Vector& a, const Vector& b) ;
423  static float distanceSquaredVec3 (const Vector& a, const Vector& b) ;
431  static float distanceSquaredVec4 (const Vector& a, const Vector& b) ;
432  // Dot product
440  static float dotVec2 (const Vector& a, const Vector& b) ;
448  static float dotVec3 (const Vector& a, const Vector& b) ;
456  static float dotVec4 (const Vector& a, const Vector& b) ;
457  // Cross product
465  static Vector crossVec3 (const Vector& a, const Vector& b) ;
466  } ;
467 
468  using FloatVector = Vector ;
469 }
nkMaths::Vector::distanceVec3
static float distanceVec3(const Vector &a, const Vector &b)
nkMaths::Vector::getLengthVec4
float getLengthVec4() const
nkMaths::Vector::getDistanceSquaredVec2
float getDistanceSquaredVec2(const Vector &other) const
nkMaths::Vector::Vector
Vector(float x, float y, float z, float w)
nkMaths::Vector::distanceSquaredVec2
static float distanceSquaredVec2(const Vector &a, const Vector &b)
nkMaths::IntVector
A 4-component vector class, with integers.
Definition: IntVector.h:12
nkMaths::Vector::distanceVec2
static float distanceVec2(const Vector &a, const Vector &b)
nkMaths::Vector::operator>
bool operator>(const Vector &other) const
nkMaths::Vector::setAsCrossVec3
void setAsCrossVec3(const Vector &other)
nkMaths::Vector::getCrossVec3
Vector getCrossVec3(const Vector &other) const
nkMaths
Encompasses all API of component NilkinsMaths.
Definition: IntVector.h:7
nkMaths::Vector::operator==
bool operator==(const Vector &other) const
nkMaths::Vector::operator<
bool operator<(const Vector &other) const
nkMaths::Vector::operator+=
void operator+=(const Vector &other)
nkMaths::Quaternion
A quaternion, symbolizing rotations as a 4D vector.
Definition: Quaternion.h:14
nkMaths::Vector::operator+
Vector operator+(const Vector &other) const
nkMaths::Vector::getLengthVec3
float getLengthVec3() const
nkMaths::Vector::distanceSquaredVec4
static float distanceSquaredVec4(const Vector &a, const Vector &b)
nkMaths::Vector::getDistanceVec4
float getDistanceVec4(const Vector &other) const
nkMaths::Vector::dotVec3
static float dotVec3(const Vector &a, const Vector &b)
nkMaths::Vector::getLengthSquaredVec2
float getLengthSquaredVec2() const
nkMaths::Vector::dotVec4
static float dotVec4(const Vector &a, const Vector &b)
nkMaths::Vector::_x
float _x
X component of the vector.
Definition: Vector.h:16
nkMaths::Matrix
Represents a 4x4 float matrix.
Definition: Matrix.h:14
nkMaths::Vector::getDistanceVec2
float getDistanceVec2(const Vector &other) const
nkMaths::Vector::Vector
Vector()
nkMaths::Vector::normalizeVec2
void normalizeVec2()
nkMaths::Vector::normalizeVec3
void normalizeVec3()
nkMaths::Vector::getDistanceSquaredVec4
float getDistanceSquaredVec4(const Vector &other) const
nkMaths::Vector::operator*
Vector operator*(const Vector &other) const
nkMaths::Vector::distanceSquaredVec3
static float distanceSquaredVec3(const Vector &a, const Vector &b)
nkMaths::Vector::operator-=
void operator-=(const Vector &other)
nkMaths::Vector::operator<=
bool operator<=(const Vector &other) const
nkMaths::Vector::Vector
Vector(const Vector &other)
nkMaths::Vector::~Vector
~Vector()
nkMaths::Vector::operator/=
void operator/=(const Vector &other)
nkMemory::String
Class holding information about a string, with ownership over the data.
Definition: String.h:22
nkMemory::StringView
Class holding information about a string, with no ownership over the data.
Definition: StringView.h:22
nkMaths::Vector::Vector
Vector(const IntVector &other)
nkMaths::Vector::crossVec3
static Vector crossVec3(const Vector &a, const Vector &b)
nkMaths::Vector::fromString
void fromString(const nkMemory::StringView &str)
nkMaths::Vector::toString
nkMemory::String toString() const
nkMaths::Vector::dotProductVec3
float dotProductVec3(const Vector &other) const
nkMaths::Vector::operator>=
bool operator>=(const Vector &other) const
nkMaths::Vector::_z
float _z
Z component of the vector.
Definition: Vector.h:18
nkMaths::Vector::_w
float _w
W component of the vector.
Definition: Vector.h:19
nkMaths::Vector::getLengthSquaredVec3
float getLengthSquaredVec3() const
nkMaths::Vector::dotProductVec4
float dotProductVec4(const Vector &other) const
nkMaths::Vector::getDistanceVec3
float getDistanceVec3(const Vector &other) const
nkMaths::Vector::getNormalizedVec2
Vector getNormalizedVec2() const
nkMaths::Vector::getNormalizedVec3
Vector getNormalizedVec3() const
nkMaths::Vector::Vector
Vector(float x, float y)
nkMaths::Vector::_y
float _y
Y component of the vector.
Definition: Vector.h:17
nkMaths::Vector::getNormalizedVec4
Vector getNormalizedVec4() const
nkMaths::Vector::getLengthVec2
float getLengthVec2() const
nkMaths::Vector::dotProductVec2
float dotProductVec2(const Vector &other) const
nkMaths::Vector::operator-
Vector operator-(const Vector &other) const
nkMaths::Vector::getLengthSquaredVec4
float getLengthSquaredVec4() const
nkMaths::Vector::operator!=
bool operator!=(const Vector &other) const
nkMaths::Vector::operator*=
void operator*=(const Vector &other)
nkMaths::Vector::operator/
Vector operator/(const Vector &other) const
nkMaths::Vector::getDistanceSquaredVec3
float getDistanceSquaredVec3(const Vector &other) const
nkMaths::Vector::operator=
Vector & operator=(const Vector &other)
nkMaths::Vector::Vector
Vector(float x, float y, float z)
nkMaths::Vector
A 4-component vector class, with floats.
Definition: Vector.h:12
nkMaths::Vector::distanceVec4
static float distanceVec4(const Vector &a, const Vector &b)
nkMaths::Vector::normalizeVec4
void normalizeVec4()
nkMaths::Vector::dotVec2
static float dotVec2(const Vector &a, const Vector &b)